import {defineStore} from "pinia"

export const moduleStore = defineStore({
    id: "module",
    state() {
        return {
            isFullscreen: false, // 是否全屏
            isOpenVoice: true, // 是否开启语音播报
            module_num: null,
            module_list: [],
            selectModule: [],
            isShowTip: true, // 是否有报警信息的提醒
            device_currentId: 1, // 当前设备的编号
            alarm_type: 0, // 报警类型 0 => 正常 1 => 正在报警 2 => 静止报警提醒
            systemInfo: {
                diskInfo: {
                    diskPath: "c:",
                    currentPath: "C:\\Users\\user\\Desktop\\node_server",
                    diskUsage: "18.04",
                    free: "100",
                    size: "381.54"
                  },
                  memInfo: {
                      freeMem: "10940.20",
                      totalMem: "16072.73",
                      freememPercentage: "93.19"
                  },
                  cpuInfo: {
                      cpuCount: 12,
                      cpuUsage: "12.92",
                      cpuFree: "87.10",
                      platform: "12th Gen Intel(R) Core(TM) i5-12400 win32"
                  }
            },
            // 监测报警是否为同一个
            deviceStatusList: [
                new Map(),
                new Map(),
                new Map(),
                new Map(),
                new Map(),
                new Map(),
                new Map(),
                new Map(),
                new Map(),
                new Map()
            ]
        }
    },
    actions: {
        // 初始化模块列表
        initModuleList() {
                //@ts-ignore
                for(let i =0;i<this.module_num;i++) {
                    //@ts-ignore
                    this.selectModule.push({
                        id: i+1,
                        isChecked: false,
                        status: true
                    })
                }
        }
    },
    getters: {
        sleepModule(state) {
            return state.selectModule.filter(item => !item.status)
        },
        wakeupModule(state) {
            return state.selectModule.filter(item => item.status)
        }
    }
})